import actionTypes from '../actions/actionTypes'
// 给状态设置默认值
const data = {
    id: '1',
    name: 'zhangshan',
    sex: 'nan',
    age: 12
}
const initState = {
    ...data,
    isLoading: false,
    nums: 1
}

export default (state = initState, action) => {
    switch (action.type) {
        case actionTypes.SETTING_THEME:
            const data = {
                ...state,
                success: true
            }
            return {
                data,
                isLoading: true
            }
            break;
        case actionTypes.SEETING_THEME_SUCCESS:
            const info = {
                ...state,
                success: true,
                ok: true
            }
            return {
                info,
                isLoading: true
            }
            break;
        case actionTypes.ADD:
            state.nums = action.payload.data + state.nums;
            return {
                ...state
            }
            break;
        case actionTypes.SUB:
            state.nums = state.nums - action.payload.data;
            return {
                ...state
            }
            break;
        default:
            return state;
    }
}